(function(global, doc){
    var parent = null
    sendBtn.onclick = function() {
        parent && parent.postMessage(text.value, '*')
        if (parent) text.value = ''
    }     
    
    global.addEventListener('message', function(e) {
        parent = e.source
        msg.innerHTML = e.data
    })
}(this, document))